package com.lvyerose.hello.asymmetricgridviewtest.mode;

import android.os.Parcel;

import com.felipecsl.asymmetricgridview.library.model.AsymmetricItem;

/**
 * Created by Rose on 2015/6/29.
 * 用于适配器的数据源，该数据源必须实现AsymmetricItem接口
 */
public class CustomItem implements AsymmetricItem{
    //占列数
    private int columnSpan;
    //占横数
    private int rowSpan;
    //item第几项
    private int position;

    //初始化成员变量
    public CustomItem(int columnSpan , int rowSpan ,int position){
        this.columnSpan = columnSpan;
        this.rowSpan = rowSpan;
        this.position = position;
    }

    //如调用该构造器进行实例化  则为成员变量默认赋值（目前当item的rowSpan = 2 columnSpan = 2时可以达到最佳的状态。）
    public CustomItem(){
        this(2,2,0);
    }
    @Override
    public int getColumnSpan() {
        return columnSpan;
    }

    @Override
    public int getRowSpan() {
        return rowSpan;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * 自定义方法，返回传统adapter中需要获取的数据，此处返回位置信息作为TextView的数据
     * @return 返回位置信息
     */
    public int getPosition(){
        return position;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(columnSpan);
        dest.writeInt(rowSpan);
        dest.writeInt(position);
    }
}
